package gui;

import javax.swing.JDialog;
import javax.swing.JFrame;

import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.JButton;

/**
 * 
 * @author Christian
 *
 * @since 0.15e
 */
public class UpdateDialog extends JDialog {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * 
	 */
	private JPanel jPanel = null;
	
	/**
	 * 
	 */
	private JLabel jLabel = null;
	
	/**
	 * 
	 */
	private JButton jButton = null;
	
	/**
	 * 
	 */
	private JButton jButton1 = null;
	
	/**
	 * This method initializes
	 * 
	 * @param updateinfo Gezeigte Nachricht
	 * @param b vorgegebener wert
	 * @param frame Frame vom Heldentool
	 * @param text headzeile
	 * 
	 */
	public UpdateDialog(JFrame frame, String text, boolean b, String updateinfo) {

		super(frame, text, b);
		initialize();
		jLabel.setText(updateinfo);
	}
	
	/**
	 * 
	 * @return gibt es selbst zurück
	 */
	private JDialog getDialog() {

		return this;
	}
	
	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {

		this.setSize(new Dimension(284, 221));
		this.setContentPane(getJPanel());
	}
	
	/**
	 * This method initializes jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel() {

		if (jPanel == null) {
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.gridy = 2;
			gridBagConstraints11.insets = new Insets(5, 5, 5, 5);
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.insets = new Insets(5, 5, 5, 5);
			gridBagConstraints1.gridy = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 0;
			gridBagConstraints.insets = new Insets(5, 5, 5, 5);
			jLabel = new JLabel();
			jLabel.setText("Update");
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(jLabel, gridBagConstraints);
			jPanel.add(getJButton(), gridBagConstraints1);
			jPanel.add(getJButton1(), gridBagConstraints11);
		}
		return jPanel;
	}
	
	/**
	 * This method initializes jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton() {

		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("zur Updateseite");
			jButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					try {
						Desktop.getDesktop().browse(new URI("http://zauberinfo.de.gg/"));
					} catch (IOException e1) {
						
						e1.printStackTrace();
					} catch (URISyntaxException e1) {
						
						e1.printStackTrace();
					}
				}
			});
		}
		return jButton;
	}
	
	/**
	 * This method initializes jButton1
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton1() {

		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Weiter");
			jButton1.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					getDialog().dispose();
				}
			});
		}
		return jButton1;
	}
} // @jve:decl-index=0:visual-constraint="197,9"
